package ihm;

import java.awt.EventQueue;
import java.awt.Font;
import java.util.Vector;

import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.TitledBorder;

import metier.Client;
import metier.Employe;
import dao.DAO_Client;
import dao.DAO_Employe;

public class FenetreVoirClient extends JInternalFrame
{
	private JTable lstClient;
	private Vector<Client> lesClients;
	private Object[][] lignes;
	private JScrollPane scrollPane;
	private JPanel panel;

	public FenetreVoirClient()
	{
		setRootPaneCheckingEnabled(false);
		javax.swing.plaf.InternalFrameUI ui = this.getUI();
		((javax.swing.plaf.basic.BasicInternalFrameUI)ui).setNorthPane(null);
		setBorder(null);
		
		setBounds(100, 100, 710, 440);
		this.lesClients = DAO_Client.getLesClients();
		setBounds(100, 100, 710, 440);
		getContentPane().setLayout(null);	
		
		
		String titres[]={"IDCLIENT","NOM","PRENOM","CODE POSTAL","VILLE","TELEPHONE"};
		lignes=new Object[lesClients.size()][6];
		int i = 0;
		for (Client c : lesClients)
		{
		    	lignes[i][0] = c.getIdClient();
		    	lignes[i][1] = c.getNom();
		    	lignes[i][2] = c.getPrenom();
		    	lignes[i][3] = c.getCodePostal();
		    	lignes[i][4] = c.getVille();
		    	lignes[i][5] = c.getTelephone();
		   	i++;
		}
		
		scrollPane = new JScrollPane();
		scrollPane.setBounds(33, 57, 632, 257);
		getContentPane().add(scrollPane);
		this.lstClient=new JTable(lignes,titres);
		scrollPane.setViewportView(lstClient);
		
		panel = new JPanel();
		panel.setBorder(new TitledBorder(null, "Voir les employ\u00E9s", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.BOLD, 13)));
		panel.setBounds(10, 29, 674, 307);
		getContentPane().add(panel);
		
		// Block la saisi du tableau
		lstClient.setEnabled(false);
	}
}
